	ld	a,h
	or	l
	j%1	%2
	ld	hl,%3
=
	bool	hl
	j%1	%2
	ld	hl,%3

	push	hl
	ld	hl,%1	;const
	pop	de
=
	ex	de,hl
	ld	hl,%1	;const

%check 0 <= %1 <= 254
	ld	hl,%1	;const
	add	hl,sp
	ld	l,(hl)
	ld	h,0
=
	ld	hl,(sp+%1)
	ld	h,0

%check 0 <= %1 <= 254
	ld	hl,%1	;const
	add	hl,sp
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	hl,%2
=
	ld	hl,(sp+%1)
	ex	de,hl
	ld	hl,%2

%check 0 <= %1 <= 254
	ld	hl,%1	;const
	add	hl,sp
	call	l_gint	;
=
	ld	hl,(sp+%1)

%check 0 <= %1 <= 254
	ld	hl,%1	;const
	add	hl,sp
	ld	a,(hl)
	inc	hl
	ld	h,(hl)
	ld	l,a
=
	ld	hl,(sp+%1)

%check 0 <= %1 <= 254
	ld	hl,%1	;const
	add	hl,sp
	ld	c,(hl)
	inc	hl
	ld	b,(hl)
	ld	hl,%2
=
	ld	hl,(sp+%1)
	ld	c,l
	ld	b,h
	ld	hl,%2

	ld	c,l
	ld	b,h
	ld	hl,%2	;const
	add	hl,bc
=
	ld	bc,%2
	add	hl,bc

%check 0 <= %1 <= 254
	ld	hl,%1	;const
	add	hl,sp
	inc	(hl)
	ld	a,(hl)
	inc	hl
	jr	nz,ASMPC+3
	inc	(hl)
	ld	h,(hl)
	ld	l,a
=
	ld	hl,(sp+%1)
	inc	hl
	ld	(sp+%1),hl

%check 0 <= %1 <= 254
	ld	hl,%1	;const
	add	hl,sp
	dec	(hl)
	ld	a,(hl)
	inc	hl
	cp	255
	jr	nz,ASMPC+3
	dec	(hl)
	ld	h,(hl)
	ld	l,a
=
	ld	hl,(sp+%1)
	dec	hl
	ld	(sp+%1),hl

%check 0 <= %1 <= 254
	ld	hl,%1	;const
	add	hl,sp
	ld	de,%2
	ex	de,hl
	call	l_pint
=
	ld	hl,%2
	ld	(sp+%1),hl

%check 0 <= %1 <= 255
	ld	hl,%1	;const
	call	l_gintspsp	;
=
	ld	hl,(sp+%1)
	push	hl

%check 0 <= %1 <= 251
	ld	hl,%1	;const
	add	hl,sp
	call	l_glong
=
	ld	hl,(sp+%eval(%1 2 +))
	ex	de,hl
	ld	hl,(sp+%1)

%check 0 <= %1 <= 253
	ld	hl,%1	;const
	add	hl,sp
	call	l_gint
=
	ld	hl,(sp+%1)

%check 0 <= %1 <= 127
	ld	hl,%1	;const
	add	hl,sp
	ld	sp,hl
	ret
=
	add	sp,%1
	ret

%check 65408 <= %1 <= 65535
	ld	hl,%1	;const
	add	hl,sp
	ld	sp,hl
	ld	hl,%2
=
	add	sp,+(%1 - 65536)
	ld	hl,%2

	call	l_or
=
	or	hl,de

	call	l_and
=
	and	hl,de

	pop	bc
	push	hl
=
	ld	(sp+0),hl

	srl	h
	rr	l
=
	and	a
	rr	hl

	rr	h
	rr	l
=
	rr	hl

	srl	d
	rr	e
=
	and	a
	rr	de

	ld	a,2
	call	l_long_aslo
=
	add	hl,hl
	rl	de
	add	hl,hl
	rl	de

	rl	e
	rl	d
=
	rl	de

%check -128 <= %1 <= 126
	inc	hl
	ld	hl,(hl + %1)
=
	ld	hl,(hl + %1 + 1)

	inc	hl
	call	l_gint	;
=
	ld	hl,(hl + 1)

%check -128 <= %1 <= 127
	ld	bc,%1
	add	hl,bc
	call	l_gint	;
=
	ld	hl,(hl+%1)

	call	l_gint	;
=
	ld	hl,(hl+0)

	ld	hl,0	;const
=
	bool	hl
	rr	hl

	pop	hl
	push	hl
=
	ld	hl,(sp+0)

	pop	bc
	ld	hl,(sp+0)
	push	bc
=
	ld	hl,(sp+2)

; bool clears the carry flag
=


	call	l_lneg
	jp	c,%1	;%8
=
	bool	hl
	dec	hl
	bool	hl
	jp	nz,%1	;%8

	call	l_lneg
	jp	nc,%1	;%8
=
	bool	hl
	dec	hl
	bool	hl
	jp	z,%1	;%8

	call	l_lneg
	call	c,%1
=
	bool	hl
	dec	hl
	bool	hl
	call	nz,%1

	call	l_lneg
	call	nc,%1
=
	bool	hl
	dec	hl
	bool	hl
	call	z,%1

	call	l_lneg
	ccf
	call	c,%1
=
	bool	hl
	dec	hl
	bool	hl
	call	nz,%1

	call	l_lneg
	ccf
	call	nc,%1
=
	bool	hl
	dec	hl
	bool	hl
	call	z,%1

	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	hl,%1
=
	ld	hl,(hl+0)
	ex	de,hl
	ld	hl,%1

%check -127 <= %1 <= 126
	ld	bc,%1
	add	hl,bc
	ld	l,(hl)
	ld	h,0
=
	ld	hl,(hl+%1)
	ld	h,0
